package org.example.setup.service.impl;

import org.example.model.domain.express.ExpressAccount;
import org.example.model.domain.express.ExpressList;
import org.example.setup.mapper.ExpressListMapper;
import org.example.setup.service.ExpressListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExperssListServiceImpl implements ExpressListService {

    @Autowired
    private ExpressListMapper expressListMapper;

    // 更新用户手机号码
    @Override
    public int userPhoneUpdate(ExpressList expressList) {
        try {
            return expressListMapper.userPhoneUpdate(expressList);
        } catch (Exception e) {
            // 记录日志或进行适当的错误处理
            e.printStackTrace();
            return -1;
        }
    }

    // 更新用户密码
    @Override
    public int userPasswordUpdate(ExpressList expressList) {
        try {
            return expressListMapper.userPasswordUpdate(expressList);
        } catch (Exception e) {
            // 记录日志或进行适当的错误处理
            e.printStackTrace();
            return -1;
        }
    }

    // 更新用户支付密码
    @Override
    public int userPayPasswordUpdate(ExpressList expressList) {
        try {
            return expressListMapper.userPayPasswordUpdate(expressList);
        } catch (Exception e) {
            // 记录日志或进行适当的错误处理
            e.printStackTrace();
            return -1;
        }
    }

    // 删除快递记录
    @Override
    public int Delete(ExpressList expressList) {
        try {
            return expressListMapper.delete(expressList);
        } catch (Exception e) {
            // 记录日志或进行适当的错误处理
            e.printStackTrace();
            return -1;
        }
    }

    // 检查手机号码是否重复
    @Override
    public Boolean phoneRepeat(String phone) {
        try {
            ExpressAccount expressAccount = expressListMapper.phoneYz(phone);
            if (expressAccount!= null) {
                return false;
            } else {
                return true;
            }
        } catch (Exception e) {
            // 记录日志或进行适当的错误处理
            e.printStackTrace();
            return false;
        }
    }
}
